package com.itheima.homework.加强训练.Test2;

/**
 * @Author 王加鑫
 * @Date 2021/5/10 21:27
 * @Version 1.0
 */
public class Test2 {
    public static void main(String[] args) {
        InterA interA = new InterA() {
            @Override
            public void show() {
                System.out.println("InterA的匿名内部类执行了");
            }
        };
        interA.show();

        InterA interA1 = () -> System.out.println("InterA的lambda执行了");
        interA1.show();


        InterB interB = new InterB() {
            @Override
            public void method(int num) {
                System.out.println("InterB的匿名内部类执行了"+num);
            }
        };
        interB.method(20);

        InterB interB1 = System.out::println;
        interB1.method(50);

        InterC interC = new InterC() {
            @Override
            public String function() {
                return "InterC的匿名内部类执行了";
            }
        };
        System.out.println(interC.function());

        InterC interC1 = () -> "InterC的lambda执行了";
        System.out.println(interC1.function());

        InterD interD = new InterD() {
            @Override
            public int niubility() {
                int num = (int)(Math.random() * 10);
                return num;
            }
        };
        System.out.println(interD.niubility());

        InterD interD1 = () -> 10;
        System.out.println(interD1.niubility());



    }
}

interface InterA{
    public abstract void show();

}

interface InterB{
    public abstract void method(int num);

}

interface InterC{
    public abstract String function();

}

interface InterD{
    public abstract int niubility();

}
